{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-input-inline layui-form">
                            <select name="status" lay-search="" class="layui-input">
                                <option value="">不限处理状态</option>
                                <option value="1">待处理</option>
                                <option value="2">已同意</option>
                                <option value="4">已拒绝</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="back" lay-search="" class="layui-input">
                                <option value="">不限回寄状态</option>
                                <option value="1">未回寄</option>
                                <option value="2">已回寄</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="is_send" id="n_range" lay-search="" class="layui-input">
                                <option value="">不限发货状态</option>
                                <option value="0">未发货</option>
                                <option value="1">已发货</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="push" lay-search="" class="layui-input">
                                <option value="">不限推送状态</option>
                                <option value="1">未推送给erp</option>
                                <option value="2">已推送给erp</option>
                                <option value="3">未对接之前</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="school" lay-search="" class="layui-input">
                                <option value="" >全部学校</option>
                                {foreach name="schools" item="v"}
                                <option value="{$v.school_erp}">{$v.school_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" class="layui-input search" name="year" placeholder="年份"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="n_title" class="layui-input search" name="n_title" placeholder="退单号/原单号/快递号/手机号"/>
                        </div>
                        <div class="layui-input-inline" style="border: 1px solid mediumseagreen">
                            <input type="text"  name="start" onclick="wk.lay_date(this);" readonly class="layui-input layer-date search" placeholder="创建时间-起" />
                        </div>
                        <div class="layui-input-inline" style="border: 1px solid mediumseagreen">
                            <input type="text"  name="end" onclick="wk.lay_date(this);" readonly class="layui-input layer-date search" placeholder="创建时间-止" />
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">
                                重置
                            </button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('excelIn')}');">
                            <i class="fa fa-file-excel-o"></i> 物流信息导入
                        </button>
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-print"></i> 导出汇总</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllDetail"><i class="fa fa-print"></i> 导出明细</a></li>
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="back">
                        {{# if(d.express_no){ }}
                        {{d.express_no}}
                        {{# }else{ }}
                        <span style="color: red;">未回寄</span>
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="status">
                        {{# if(d.status == 1){ }}
                        待处理
                        {{# } }}
                        {{# if(d.status == 2){ }}
                        已同意
                        {{# } }}
                        {{# if(d.status == 3){ }}
                        已拒绝
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="is_send">
                        {{# if(d.status == 2){ }}
                            {{# if(d.is_send == 0){ }}
                        <span style="color: red;">未发货</span>
                            {{# } }}

                            {{# if(d.is_send == 1){ }}
                        <span style="color: mediumseagreen;">已发货</span>
                            {{# } }}
                        {{# } else {}}
                        -
                        {{# } }}
                    </script>
                    <script type="text/html" id="order_push_erp">
                        {{# if(d.erp_push == 1){ }}
                        未推送
                        {{# } }}
                        {{# if(d.erp_push == 2){ }}
                        已推送
                        {{# } }}
                        {{# if(d.erp_push == 3){ }}
                        未对接前
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('orderInfo')}?tui_id={{d.tui_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情"><i class="fa fa-edit">详情</i></a>
                        {{# if(d.status == 1){ }}
                        <a href="javascript:;" onclick="wk.layer_show('审核', '{:url('orderYesNo')}?tui_id={{d.tui_id}}')" class="btn btn-warning btn-xs m-r-xs" title="审核"><i class="fa fa-edit">审核</i></a>
                        {{# } }}
                        {{# if(d.status == 2){ }}
                            {{# if(d.express_no){ }}
                                {{# if(d.tui_sure_get == 1){ }}
                                    <a href="javascript:;" onclick="wk.layer_show('查看回寄物流', '{:url('Orderps/wuliuInfo')}?express_no={{d.express_no}}')" class="btn btn-warning btn-xs m-r-xs" title="查看回寄物流"><i class="fa fa-edit">查看回寄物流</i></a>
                                    <a href="javascript:;" onclick="wk.layer_show('待确认收货', '{:url('sureGet')}?tui_id={{d.tui_id}}&type={{d.type}}')" class="btn btn-warning btn-xs m-r-xs" title="待确认收货"><i class="fa fa-save">待确认收货</i></a>
                                {{# }else{ }}
                                    {{# if(d.is_send == 0){ }}
                                    <a href="javascript:;" onclick="wk.layer_show('快递发货', '{:url('orderSend')}?tui_id={{d.tui_id}}')" class="btn btn-warning btn-xs m-r-xs" title="快递发货"><i class="fa fa-edit">快递发货</i></a>
                                    {{# }else{ }}
                                    <a href="javascript:;" onclick="wk.layer_show('查看发货物流', '{:url('Orderps/wuliuInfo')}?express_no={{d.merchant_express_no}}')" class="btn btn-warning btn-xs m-r-xs" title="查看发货物流"><i class="fa fa-edit">查看发货物流</i></a>
                                    <a href="javascript:;" onclick="wk.layer_show('修改快递', '{:url('orderSend')}?tui_id={{d.tui_id}}')" class="btn btn-primary btn-xs m-r-xs" title="修改快递"><i class="fa fa-edit">修改快递</i></a>
                                    {{# } }}
                                {{# } }}
                            {{# }else{ }}
                                 <a href="javascript:;" style="color: red">待回寄</a>
                            {{# } }}
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Ordertuips/index")}'
            , response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 100
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type: 'numbers', width: 80, title: '序号'}
                , {field: 'order_erp_wl_no', width: '', title: '退货单号', align: 'center'}
                , {field: 'order_oldno', width: '', title: '原订单号', align: 'center'}
                , {field: 'school_name', width: '', title: '统购名称', align: 'center' ,templet: function(d){
                    return d.school_name + '第' + d.order_erp_year + '级';
                }}
                , {field: 'name', width: '', title: '套装名字', align: 'center'}
                , {field: 'erp_new_size', width: '', title: '调换尺码', align: 'center'}
                , {field: 'allnum', width: '', title: '套装数量', align: 'center'}
                , {field: 'express', width: '', title: '快递公司', align: 'center'}
                , {field: 'express_no', width: '', title: '快递单号', align: 'center', toolbar: '#back'}
                , {field: 'uson_username', width: '', title: '学生名字', align: 'center'}
                , {field: 'uson_parent_phone', width: '', title: '父母电话', align: 'center'}
                , {field: 'created_at', width: '', title: '创建时间', align: 'center'}
                , {field: 'remark', width: '', title: '换货备注', align: 'center'}
                , {field: 'status', width: '', title: '是否同意', align: 'center', toolbar: '#status'}
                , {field: 'is_send', width: '', title: '售后进度', align: 'center', toolbar: '#is_send'}
                , {field: 'erp_push', width: '150', title: '是否推送erp', align: 'center', toolbar: '#order_push_erp'}
                , {fixed: 'right', width: 300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeGoodStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOut')}");
            },
            excelAllDetail: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutAll')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                , data = checkStatus.data;
            $.each(data, function (index, item) {
                ids.push(item['n_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>